const store = {
    namespaced: true,  //带命名空间的模块
    state: {
        //设备数据字典
        equipData: {
            //币种
            currencyForm: [],
            //通用流程状态
            state: [
                {
                    value: -1,
                    label: '已删除'
                },
                {
                    value: 0,
                    label: '草稿'
                },
                {
                    value: 1,
                    label: '审核中'
                },
                {
                    value: 2,
                    label: '已审核'
                },
                {
                    value: 5,
                    label: '已作废'
                },
                {
                    value: 9,
                    label: '共享审核中'
                },
                {
                    value: 10,
                    label: '已增加'
                },
                {
                    value: 20,
                    label: '已锁定'
                }
            ],
            //传输财务共享
            shareFrom: [
                {
                    value: 0,
                    label: '未传'
                },
                {
                    value: 1,
                    label: '返回修改'
                },
                {
                    value: 2,
                    label: '财务共享审核中'
                },
                {
                    value: 3,
                    label: '已传'
                },
            ],
            //设备状况
            equipCondition: [
                {
                    value: '0',
                    label: '良好'
                },
                {
                    value: '1',
                    label: '一般'
                },
                {
                    value: '2',
                    label: '差'
                },
            ],
            //租赁类型
            leaseTypeList: [
                {
                    value: '0',
                    label: '外租'
                },
                {
                    value: '1',
                    label: '内租'
                },
                {
                    value: '2',
                    label: '临租'
                },
            ],
            //保养周期
            maintenanceCycle: [
                {
                    value: '0',
                    label: '每月'
                },
                {
                    value: '1',
                    label: '每季度'
                },
                {
                    value: '2',
                    label: '每半年'
                },
                {
                    value: '3',
                    label: '每年'
                },
            ],
            //工作状态
            workStatus: [
                // {
                //     value: '-1',
                //     label: '请选择'
                // },
                {
                    value: 0,
                    label: '禁用'
                },
                {
                    value: 1,
                    label: '待用'
                },
                {
                    value: 2,
                    label: '在用'
                },
            ],
            //外协设备来源
            equipmentSource: [
                {
                    value: '0',
                    label: '新购'
                },
                {
                    value: '1',
                    label: '自有'
                },
                {
                    value: '2',
                    label: '租赁'
                },
            ],
            //进退场状态
            enterExitStatus: [
                {
                    value: '0',
                    label: '进场'
                },
                {
                    value: '1',
                    label: '退场'
                },
            ],
            //设备属性
            deviceProperties: [
                {
                    value: '0',
                    label: '自有'
                },
                {
                    value: '1',
                    label: '租赁'
                },
            ],
            //台账状态
            accountStatus: [
                {
                    value: '0',
                    label: '正常'
                },
                {
                    value: '1',
                    label: '已退场'
                },
                {
                    value: '2',
                    label: '已作废'
                },
                {
                    value: '3',
                    label: '已销账'
                },
            ],
            typeList: [ //申请类型
                { value: '0', label: '全部' },
                { value: '1', label: '报废' },
                { value: '2', label: '处置' },
            ],
            scrapTypeList: [ //报废类型
                { value: '0', label: '正常报废' },
                { value: '1', label: '异常报废' },
            ],
            redState: [//红单状态
                {
                    value: '0',
                    label: '未冲销'
                },
                {
                    value: '1',
                    label: '冲销中'
                },
                {
                    value: '2',
                    label: '已冲'
                },
                {
                    value: '3',
                    label: '红单'
                },
            ],
            otherType: [  //其他类型
                {
                    value: '0',
                    label: '记录'
                },
                {
                    value: '1',
                    label: '其他申请'
                },
                {
                    value: '2',
                    label: '报停申请'
                },
                {
                    value: '3',
                    label: '报停启用申请'
                }
            ],
            //检查类型
            checkType: [
                {
                    value: 0,
                    label: '自行检查'
                },
                {
                    value: 1,
                    label: '项目部检查'
                },
            ],
            //计时单位
            timeUnitList: [],
            //考核等级
            assessmentLevel: ['差', '一般', '良好', '优秀'],
            //设备状态
            equipStatus: [],
            //维保类型
            maintenanceType: [],
            //使用类型
            useType: [],
            //计量方式
            measurementMode: [],
            //处置方式
            processModeList: [],
            //计量单位
            unitMeasure: [],
            //运行状态
            runningState: [],
            // 设备结算的单据状态
            settleState: [
                {
                    value: -1,
                    label: '已删除'
                },
                {
                    value: 0,
                    label: '草稿'
                },
                {
                    value: 1,
                    label: '审核中'
                },
                {
                    value: 2,
                    label: '已审核'
                },
                {
                    value: 5,
                    label: '已作废'
                },
                {
                    value: 9,
                    label: '共享审核中'
                },
            ]
        }
    },
    mutations: {
        setScrapTypeListMutations ({ equipData }, data) {
            equipData.scrapTypeList = data
        },
        //更新币种
        setCurrencyFormMutations ({ equipData }, data) {
            equipData.currencyForm = data
        },
        //更新计时单位
        setTimeUnitListMutations ({ equipData }, data) {
            equipData.timeUnitList = data
        },
        //更新设备状态
        setEquipStatusMutations ({ equipData }, data) {
            equipData.equipStatus = data
        },
        //更新维保类型
        setMaintenanceTypeMutations ({ equipData }, data) {
            equipData.maintenanceType = data
        },
        //更新使用类型
        setUseTypeMutations ({ equipData }, data) {
            equipData.useType = data
        },
        //更新计量方式
        setMeasurementModeMutations ({ equipData }, data) {
            equipData.measurementMode = data
        },
        //更新处置方式
        setProcessModeListMutations ({ equipData }, data) {
            equipData.processModeList = data
        },
        //更新计量单位
        setUnitMeasureMutations ({ equipData }, data) {
            equipData.unitMeasure = data
        },
        //更新运行状态
        setRunningStateMutations ({ equipData }, data) {
            equipData.runningState = data
        },
    },
    actions: {
        setScrapTypeList ({ commit }) {
            let arr = [
                { value: '0', label: '正常报废' },
                { value: '1', label: '异常报废' },
            ]
            commit('setScrapTypeListMutations', arr)
        },
        //更新币种
        setCurrencyForm ({ commit, rootState }) {
            if (!rootState.userInfo?.orgInfo?.orgId) return
            return import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue1({
                    dicName: '币种',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setCurrencyFormMutations', arr)
                })
            })
        },
        //更新计时单位
        setTimeUnitList ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '计时单位',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setTimeUnitListMutations', arr)
                })
            })
        },
        //更新设备状态
        setEquipStatus ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '设备状态',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setEquipStatusMutations', arr)
                })
            })
        },
        //更新维保类型
        setMaintenanceType ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '维保类型',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setMaintenanceTypeMutations', arr)
                })
            })
        },
        //更新使用类型
        setUseType ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '使用类型',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setUseTypeMutations', arr)
                })
            })
        },
        //更新计量方式
        setMeasurementMode ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '计量方式',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setMeasurementModeMutations', arr)
                })
            })
        },
        //更新处置方式
        setProcessModeList ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '处置方式',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setProcessModeListMutations', arr)
                })
            })
        },
        //更新计量单位
        setUnitMeasur ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '计量单位',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setUnitMeasureMutations', arr)
                })
            })
        },
        //更新运行状态
        setRunningState ({ commit }) {
            import(/* webpackChunkName: "index" */ '@/api/config/config.js').then(config => {
                config.default.configKvGetDicValue({
                    dicName: '运行状态',
                    isEnable: true
                }).then(res=>{
                    res = res.filter(x=>{
                        return x.kvStatus === 1
                    })
                    let arr = res.map(x=>{
                        let obj = {
                            value: '',
                            label: '',
                        }
                        obj.value = x.kvValue
                        obj.label = x.kvKey
                        return obj
                    })
                    commit('setRunningStateMutations', arr)
                })
            })
        },
    },
    getters: {}
}
export default store

